var _ = require('lodash');

const getSession = function (key) {
    let value = sessionStorage.getItem(key);
    if(value !== '' && value != 'undefined' && value != 'null'){
        return value;
    }
    return null;
};
const setSession = function (key,value) {
    if(_.isEmpty(key) || _.isEmpty(value)){
        return;
    }
    sessionStorage.setItem(key, value);
};

const defPropValue = {
    "prop1":"#ee6a4a",//主题色
    "prop2":"#ee6a4a",//价格显示颜色
    "prop3":"#f2f2f2",//模版背景色
    "prop8":"1",//模版头部华盛LOGO
    "prop100":"1",//二维码华盛LOGO，
    "prop101":"#ee6a4a",//二维码背景色，
    "prop102":""//二维码背景图
};
const getStylePropValue = function (propId) {
    let propValue = getSession("cache_pageStyle_prop" + propId);
    if(propValue == null){
        return defPropValue["prop" + propId];
    }
    return propValue;
};
const setStylePropValue = function (pageStyle) {
    _.forEach(pageStyle, function(value, key) {
        setSession("cache_pageStyle_" + key, value);
    });
    setSession("cache_pageStyle", JSON.stringify(pageStyle));
};

export  {
    getSession,
    setSession,
    getStylePropValue,
    setStylePropValue
};